<template>
  <div class="headers">
    <div class="header-title">后台管理</div>
    <div class="header-center"></div>
    <div class="header-user">
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          admin<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="info">个人信息</el-dropdown-item>
            <el-dropdown-item command="loginOut">退出系统</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>
<script>
export default {
  methods: {
    handleCommand(command) {
      if (command === "loginOut") {
        window.sessionStorage.clear();
        // this.$message({ type: 'info', message: '退出成功', showClose: true, center: true })
        // console.log(this)
        this.$message({
          type: "info",
          message: "退出",
          showClose: true,
          center: true,
        });
        this.$router.push("/login");
      } else if (command === "info") {
        this.$message({
          type: "info",
          message: "弹窗显示个人信息",
          showClose: true,
          center: true,
        });
        this.$router.push("/personal");
      }
      // this.$message("click on item " + command);
    },
  },
};
</script>
<style scoped>
/* 头部 */
.headers {
  height: 50px;
  line-height: 50px;
  border-bottom: 1px solid #ccc;
  display: flex;
}

/* 头部标题 */
.header-title {
  width: 200px;
  padding-left: 30px;
  font-weight: bold;
  color: dodgerblue;
}

/* 头部中间内容 */
.header-center {
  flex: 1;
}

/* 头部用户区域 */
.header-user {
  width: 100px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>
